package com.xx.service;

import com.xx.api.PayService;
import com.xx.mapper.PayMapper;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

/**
 * Seata AT模式
 */
@Slf4j
@org.springframework.stereotype.Service
@org.apache.dubbo.config.annotation.Service
public class ATPayServiceImpl implements PayService {

    @Resource
    private PayMapper payMapper;

    @Override
    @GlobalTransactional
    public int pay() {
        log.info("pay.....");
        int res = payMapper.pay();
//        if (1 == 1) {
//            throw new RuntimeException("this is a test");
//        }
        return res;
    }
}
